<%--
  Created by IntelliJ IDEA.
  User: kkk
  Date: 2022/11/21
  Time: 9:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>用户新增</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/layui/css/layui.css"/>
    <script src="${pageContext.request.contextPath}/statics/layui/layui.js"  charset="utf-8"></script>
</head>
<body>
<div style="color: #ff0000">${errorMsg}</div>
<br>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>新增用户</legend>
</fieldset>
<br>
<form class="layui-form" action="userAdd" method="post">
    <div class="layui-form-item">
        <label class="layui-form-label">部门编号</label>
        <div class="layui-input-inline">
            <input type="text" name="deptId" lay-verify="title" autocomplete="off" placeholder="请输入部门编号" class="layui-input">
            <span>${deptIdError}</span>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">账号</label>
        <div class="layui-input-inline">
            <input type="text" name="loginName" lay-verify="title" autocomplete="off" placeholder="请输入账号" class="layui-input">
            <span>${loginNameError}</span>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">用户昵称</label>
        <div class="layui-input-inline">
            <input type="text" name="userName" placeholder="请输入用户昵称" autocomplete="off"  class="layui-input">
            <span>${userNameError}</span>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">用户类型</label>
        <div class="layui-input-inline">
            <input type="text" name="userType"  autocomplete="off"  placeholder="请输入用户类型" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">用户邮箱</label>
        <div class="layui-input-inline">
            <input type="text" name="email" autocomplete="off"  placeholder="请输入用户邮箱" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机电话</label>
        <div class="layui-input-inline">
            <input type="text" name="phonenumber"  autocomplete="off" placeholder="请输入手机电话" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">性别</label>
        <div class="layui-input-inline">
            <input type="radio" name="sex" value="1" title="女" >
            <input type="radio" name="sex" value="0" title="男"  checked >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-inline">
            <input type="text" name="password" autocomplete="off"  placeholder="请输入密码" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">账号状态</label>
        <div class="layui-input-inline">
            <input type="radio" name="status" value="1" title="停用" >
            <input type="radio" name="status" value="0" title="正常" checked>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <textarea name="remark" autocomplete="off" placeholder="请输入备注" class="layui-input"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            <button type="reset" class="layui-btn layui-btn-primary" onclick="history.back()">返回</button>
        </div>
    </div>
</form>
<script>
    layui.use(['form','jquery','laydate'],function (data) {
        var form=layui.form;
        var $=layui.jquery;
        var laydate=layui.laydate;
        //验证账号是否存在
        $('#account').blur(function () {
            $.get("accountExists?account="+this.value,function (data) {
                if (data==="1"){
                    $('#accountSpan').html("账号已存在");
                    $('#account').val("");
                }else {
                    $('#accountSpan').html("");
                }
            })
        })
        //日期
        laydate.render({
            elem: '#date1'
        });
        <%--form.on('submit(demo1)',function (data) {--%>
        <%--    alert(data.field.account)--%>
        <%--    $.get("${pageContext.request.contextPath}/sysUser/userAdd",data.field,function (data) {--%>
        <%--        if (data==="1") {--%>
        <%--            alert("添加成功");--%>
        <%--            window.open("${pageContext.request.contextPath}/sysUser/toList");--%>
        <%--        }else {--%>
        <%--            alert("添加失败");--%>
        <%--            location.reload();--%>
        <%--        }--%>

        <%--    })--%>
        <%--})--%>
    })

</script>
</body>
</html>
